package scau.hotel.hotel_web.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import scau.hotel.hotel_service.service.CheckinInforService;
import scau.hotel.hotel_service.service.PaymentService;
import scau.hotel.hotel_service.vo.GetPriceVo;
import scau.hotel.hotel_model.controller.RespBean;

import javax.annotation.Resource;

/**
 * (ECharts)表控制层
 *
 * @author hombue
 * @since 2022-03-28 20:30:37
 */
@RestController
@PreAuthorize("hasAuthority('admin')")
@RequestMapping("eCharts")
@Api(value = "typeApi", tags = "ECharts图表控制器")
public class EChartsController {
    /**
     * 服务对象
     */
    @Resource
    private CheckinInforService checkinInforService;

    /**
     * 服务对象
     */
    @Resource
    private PaymentService paymentService;

    /**
     * ECharts饼状图数据接口
     * @return
     */
    @GetMapping("/pie")
    @ApiOperation("ECharts类型饼状图数据接口")
    public RespBean pie(){
        return RespBean.success(this.checkinInforService.countByRoomTypeId());
    }

    /**
     * ECharts饼状图数据接口
     * @return
     */
    @PostMapping("/line")
    @ApiOperation("ECharts营业额图数据接口")
    public RespBean line(@RequestBody GetPriceVo getPriceVo){
        return RespBean.success(this.paymentService.querySomeDayInCome(getPriceVo));
    }
}
